Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif';
Ext.namespace('ExtWsfwMain.layout');
var westPanel;
var northPanel;
var mainPanel;
var tree;
ExtWsfwMain.layout.borderLayout = function() {
	this.init();
}
// 设置树的点击事件
function treeClick(node, e) {
	if (node.isLeaf()) {
		e.stopEvent();
		var n = tab.getComponent(node.id);
		if (!n) {
			var n = tab.add({
				'id' : node.id,
				'title' : node.text,
				closable : true,
				html : '<iframe scrolling="auto" name="'
						+ node.id
						+ 'fr" frameborder="0" width="100%" height="100%" src="'
						+ node.attributes.href + '"></iframe>'
			});
		}
		tab.setActiveTab(n);
	}
}

// 生成标签页
var tab;

// 设置树的点击事件
function treeClick(node, e) {
	if (node.isLeaf()) {
		e.stopEvent();
		var n = tab.getComponent(node.id);
		if (!n) {
			var n = tab.add({
				'id' : node.id,
				'title' : node.text,
				closable : true,
				tools : [{
							id : 'maximize',
							handler : function() {
								zdh();
							}
						},
						{
							id : 'close',
							handler : function(b,a,f) {
								tabclose(b,a,f);
								//tab.close();
							}
						}],
				// handler: {doubleclic: tabclick},
				html : '<iframe scrolling="auto" name="'
						+ node.id
						+ 'fr" frameborder="0" width="100%" height="100%" src="'
						+ node.attributes.href + '"></iframe>'
			});
		}
		tab.setActiveTab(n);
	}
}

function addTab(id, title, url) {
	var n = tab.getComponent(id);
	if (!n) {
		var n = tab.add({
					'id' : id,
					title : '',
					closable : true,
					html : '<iframe scrolling="auto" name="'
							+ id
							+ 'fr" frameborder="0" width="100%" height="100%" src="'
							+ url + '"></iframe>'
				});
	}
	tab.setActiveTab(n);
}
function handleActivate(tab) {
	aa();
}
Ext.extend(ExtWsfwMain.layout.borderLayout, Ext.util.Observable, {
	init : function() {
		northPanel = new Ext.Panel({
					region : 'north',
					height : 75,
					html : $('maintop').innerHTML,
					// html:'',
					split : true,
					collapseMode : 'mini'
				});

		var southPanel = new Ext.Panel({
			region : 'south',
			height : 25,
			split : true,
			minSize : 1,
			maxSize : 25,
			collapseMode : 'mini',
			html : '<div style="float: left; margin: 5px; font: normal 12px tahoma, arial, sans-serif, 宋体;"><span style="color: blue">Copyright(R) 2013 Jiangsu  All Rights Reserved</span> &nbsp;技术支持： </div><div style="float: right; margin: 5px; font: normal 12px tahoma, arial, sans-serif, 宋体;"> 版权所有</div>'
		});

		westPanel = new Ext.Panel({
			region : 'west',
			width : 200,
			title : ' ',
			collapsible : true,
			margins : '0 0 0 0',
			layout : 'accordion',
			// afterCollapse:function(){sAlert('1');},
			html : '<div id="djfwdiv"></div>'

		});

		tab = new Ext.TabPanel({
					region : 'center',
					deferredRender : false,
					activeTab : 0,
					resizeTabs : true,
					minTabWidth : 115,
					tabWidth : 150,
					enableTabScroll : true
				});

		mainPanel = new Ext.Panel({
					renderTo : 'layout-borderlayout-main',
					layout : 'border',
					border : true,
					margins : '0 0 0 0',
					height : 40,
					//autoHeight : true,
					items : [northPanel, southPanel, westPanel, tab]
				});

		/** *****登记服务***** */

		var root = new Ext.tree.TreeNode({
					id : "root",
					text : "树的根"
				});
	    var test={aa:'aa'};
		tree = new Ext.tree.TreePanel({
					renderTo :'djfwdiv',
					animate : true,
					enableDD : false,
					border : false,
					containerScroll : true,
					rootVisible: false,
					//width : '100%',
					//id :cxtjs[i].ID+'TREE',
					selModel :new Ext.tree.MultiSelectionModel(),
					loader: new Ext.tree.TreeLoader({
						dataUrl : getLocation()+"/jsoncommon?serviceName=IndexService.getGns",
						baseParams: {
				        	bcondition: JSON.stringify(test)
				        }
					}),
		       	 	root : new Ext.tree.AsyncTreeNode({})
				})

		tree.render();
		tree.on('click', treeClick);

	},
	// -----------------模块销毁函数---------------------------
	destroy : function() {

	}

});

function initPage() {
	new ExtWsfwMain.layout.borderLayout();
	mainPanel.setHeight(document.body.clientHeight);
	//sAlert(document.body.clientWidth+'K'+document.body.clientHeight);
	var gns=[{"LEAF":false,"SJGN_DM":"0","GNS_MC":"人员管理","GNS_DM":1},{"LEAF":true,"SJGN_DM":"1","GNS_MC":"人员注册","GNS_DM":2}];
};
function initTree(){
	sAlert('谢谢到对顶顶顶顶顶顶顶顶顶顶','ERROR','提示信息');
	/*
	westPanel.removeAll();
	westPanel.add({
				title : '病人管理1',
				border : false,
				iconCls : 'tree1',
				html : '<div id="djfwdiv1" style="overflow:auto;width:100%;"></div>'
			});
	westPanel.doLayout();
	*/
}